<html>
	<head>
		<title>nTube: Embedded</title>
		<meta name="application-name" content="nTube" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<meta name="iwebkit-use-fruit-styled-layout" value="true;version=1" />
		<meta charset="UTF-8" />
		<meta name="theme-color" content="#282828" />
		<meta name="description" content="nTube: Embedded Video Player." />
		<meta name="robots" content="noindex, nofollow" />
		<meta name="apple-mobile-web-app-capable" content="yes" />
		<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
		<link rel="manifest" href="/manifest.json" />
		<link rel="preload" href="resources/promise-queues.js" as="script" />
		<link rel="preload" href="resources/libWeb.js" as="script" />
		<link rel="preload" href="resources/settings.js" as="script" />
		<link rel="preload" href="resources/base.js" as="script" />
		<link rel="preload" href="resources/base_es6_funcs.js" as="script" />
		<link rel="preload" href="resources/dash.js" as="script" />
		<link rel="preload" href="resources/settings.js" as="script" />
		<script src="resources/promise-queues.js"></script>
		<script src="resources/libWeb.js"></script>
		<script src="resources/base.js"></script>
		<script src="resources/base_es6_funcs.js"></script>
		<script src="resources/nPlayerNX.js"></script>
		<script src="resources/dash.js"></script>
		<script src="resources/settings.js"></script>
		<style>
			* {
				-webkit-font-smoothing: antialiased;
				-moz-osx-font-smoothing: grayscale;
			}

			body {
				background-color: black;
				color: white;
			}

			.poly-item {
				padding-left: 5px;
				box-shadow: 0 14px 28px rgba(255, 255, 255, 0.11), 0 10px 10px rgba(255, 255, 255, 0.08);
				border: 1px solid white;
				margin-bottom: 10px;
			}
		</style>
		<style id="_css_fonts">
			html {
				font-family: -apple-system, BlinkMacSystemFont, "Product Sans", "Google Sans", "Segoe UI", "Arial", sans-serif;
			}
		</style>
		<style id="_subtitle_css">
			::cue,
			video::-webkit-media-text-track-display,
			video::cue {
				font-family: inherit;
			}
		</style>
		<style>
			#overlay {
				position: fixed;
				/* Sit on top of the page content */
				/*display: none; /* Hidden by default */
				width: 100%;
				/* Full width (cover the whole page) */
				height: 100%;
				/* Full height (cover the whole page) */
				top: 0;
				left: 0;
				right: 0;
				bottom: 0;
				background-color: rgba(0, 0, 0, 0.5);
				/* Black background with opacity */
				z-index: 2;
				/* Specify a stack order in case you're using a different order for other elements */
				cursor: pointer;
				/* Add a pointer on hover */
			}

			#text {
				position: absolute;
				top: 50%;
				left: 50%;
				font-size: 24px;
				color: white;
				transform: translate(-50%, -50%);
				-ms-transform: translate(-50%, -50%);
			}

			.video-info-overlay {
				position: fixed;
				/* Sit on top of the page content */
				/*display: none; /* Hidden by default */
				width: 100%;
				/* Full width (cover the whole page) */
				height: 10%;
				/* Full height (cover the whole page) */
				top: 0;
				left: 0;
				right: 0;
				bottom: 0;
				background-color: rgba(0, 0, 0, 0);
				/* Black background with opacity */
				z-index: 1;
				/* Specify a stack order in case you're using a different order for other elements */
				cursor: pointer;
				/* Add a pointer on hover */
			}

			video:focus {
				outline: none;
			}
		</style>
		<script>
			function isChromeFunc() {
				try {
					return (typeof window.chrome === "object" || typeof window.chrome.runtime === "object" || typeof window.chrome.csi === "function") && typeof InstallTrigger !== "object";
				} catch (e) {
					return false;
				}
			}
			function init() {
				if (window.location.toString().contains("file:///")) {
					console.warn("nTube was opened locally, not extracting.");
					return;
				}
				var VIDEO_ID = getQueryVariable("v");
				if (VIDEO_ID === null || VIDEO_ID === undefined) {
					console.warn("nTube was opened without a video ID, not extracting.");
					return;
				}
				if (VIDEO_ID.contains("?")) {
					VIDEO_ID = VIDEO_ID.substring(0, VIDEO_ID.indexOf("?"));
				}
				if (VIDEO_ID.contains("?")) {
					VIDEO_ID = VIDEO_ID.substring(0, VIDEO_ID.indexOf("?"));
				}
				if (VIDEO_ID == null || VIDEO_ID.length == 0) {
					alert("nTube encountered an error.\r\nError: VIDEO_ID is null or blank!");
					return;
				}
				var PREFER_QUALITY = 720;
				const SETTINGS = nTubeSettings.auto();
				var allowWebM = false;
				var DASH_JS_ENABLE_QUALITY_ENFORCEMENT = false;
				var PLAYBACK_ENGINE = "rxplayer";
				var av1Action = "def";
				var ENABLE_DATA_SAVER = false;
				if (SETTINGS != null) {
					if (SETTINGS.extraction.defaultQuality) {
						PREFER_QUALITY = SETTINGS.extraction.defaultQuality;
					}
					if (SETTINGS.extraction.allowWebM) {
						allowWebM = SETTINGS.extraction.allowWebM && supportsVideoType("vp9") === "probably";
					}
					if (SETTINGS.playback.dash_js_force_quality_init) {
						DASH_JS_ENABLE_QUALITY_ENFORCEMENT = SETTINGS.playback.dash_js_force_quality_init;
					}
					if (SETTINGS.playback.playback_engine) {
						PLAYBACK_ENGINE = SETTINGS.playback.playback_engine;
					}
					if (SETTINGS.extraction.av1_behaviour) {
						av1Action = SETTINGS.extraction.av1_behaviour;
					}
					if (SETTINGS.extraction.dataSaving) {
						ENABLE_DATA_SAVER = SETTINGS.extraction.dataSaving === "on";
					}
				}
				function getUTCOffset() {
					if (window.Date && window.Date.prototype.getTimezoneOffset) {
						return new Date().getTimezoneOffset();
					} else {
						return 120;
					}
				}
				function allowAV1() {
					if (av1Action === "def") {
						if (isBattery()) return false;
						return supportsAV1playback() || getQueryVariable("av1") !== null;
					} else {
						return av1Action === "fon";
					}
				}
				const jxr = {
					next_api_version: 2,
					videoID: VIDEO_ID,
					enableAV1: allowAV1(),
					enableWebM: allowWebM || getQueryVariable("allowWebM") !== null,
					enableDashJS: nTube.nTubeUtils.isPlaybackEngineDASH(PLAYBACK_ENGINE),
					dataSaver: ENABLE_DATA_SAVER || getQueryVariable("dataSaving") !== null,
					dashJSUseCompression: false,
					dashJSAllowCaching: true,
					preferredQuality: PREFER_QUALITY,
					systemInfo: {
						utcTimezoneOffset: getUTCOffset(),
					},
					telemetry: {
						h264: supportsVideoType("h264") === "probably",
						vp9: supportsVideoType("vp9") === "probably",
						av1: supportsAV1playback(),
						client: libWeb.BrowserEnvironment.getBrowserVersion(),
						frontend: "ntube-embed",
					},
				};
				var url = "/api/get_video";
				url += "?v=" + VIDEO_ID;
				try {
					document.getElementById("url-fix").href = "/watch?v=" + VIDEO_ID;
				} catch (e) {
					console.error(e);
				}
				request(
					url,
					JSON.stringify(jxr),
					function (exception) {
						console.error(exception);
						run_promise(function () {
							document.body.style.cursor = "";
						});
						alert("nTube failed to talk with it's backend.\r\nCheck your browser's console for more information.");
					},
					function (data) {
						var jsonObject = JSON.parse(data);
						window.jsonObject = jsonObject;
						Object.freeze(window.jsonObject);
						run_async(function () {
							document.body.style.cursor = "";
						});
						if (jsonObject.error_id) {
							var error_id = jsonObject.error_id;
							if (error_id === "ERROR_UPCOMING_STREAM") {
								window.hideVideoInfo = function () {
									document.getElementById("video-overlay").style.display = "";
									document.getElementById("video-overlay").style.visibility = "";
								};
								hideVideoInfo();
								var voi = document.getElementById("video-overlay-info");
								voi.style.display = "";
								voi.style.visibility = "";
								voi.innerHTML = jsonObject.error_message;
								if (jsonObject.metadata) {
									document.title = jsonObject.metadata.title + " - nTube Embedded";
									document.getElementById("video-title").innerHTML = jsonObject.metadata.title;
								}
							} else if (error_id === "FAILED_STAGE_UNABLE_TO_GET_METADATA") {
								window.hideVideoInfo = function () {
									document.getElementById("video-overlay").style.display = "";
									document.getElementById("video-overlay").style.visibility = "";
								};
								hideVideoInfo();
								var voi = document.getElementById("video-overlay-info");
								voi.style.display = "";
								voi.style.visibility = "";
								voi.innerHTML = jsonObject.error_message;
							} else {
								console.error("nTube: Failed to extract! Error: " + jsonObject.error_id);
								if (jsonObject.error) {
									console.error(jsonObject.error);
									alert("nTube: Internal error occurred during extraction.\n\n" + jsonObject.error);
								} else {
									console.error(jsonObject.error_message);
									alert("nTube: Internal error occurred during extraction.\n\n" + jsonObject.error_message);
								}
							}
							return;
						} else {
							document.title = jsonObject.metadata.title + " - nTube Embedded";
							document.getElementById("video-title").innerHTML = jsonObject.metadata.title;
							var mainPlayer = document.getElementById("_primary_player");
							var audioPlayer = document.getElementById("_secondary_player");
							run_async(function () {
								const loop = getQueryVariable("loop");
								if (loop !== null && loop === "1") {
									mainPlayer.loop = true;
									audioPlayer.loop = true;
								}
							});
							run_async(function () {
								if (window.MediaMetadata && "mediaSession" in navigator && !(PLAYBACK_ENGINE === "redwood")) {
									var pp = id("_primary_player");
									if (pp == null) {
										try {
											pp = document.getElementsByClassName("video-stream html5-main-video")[0];
										} catch (e) {}
									}
									if (pp.tagName === "DIV") {
										pp = pp.children[0];
									}
									navigator.mediaSession.metadata = new MediaMetadata({
										title: jsonObject.metadata.title,
										artist: jsonObject.metadata.author,
										album: "Powered by nTube Embedded.",
										artwork: [
											{
												src: "https://i.ytimg.com/vi/" + VIDEO_ID + "/hqdefault.jpg",
												sizes: "480x360",
											},
											{
												src: "https://i.ytimg.com/vi/" + VIDEO_ID + "/mqdefault.jpg",
												sizes: "320x180",
											},
											{
												src: "https://i.ytimg.com/vi/" + VIDEO_ID + "/default.jpg",
												sizes: "120x90",
											},
										],
									});
									navigator.mediaSession.setActionHandler("play", function () {
										if ("mainPlayer" in window) {
											mainPlayer.play();
										} else {
											pp.play();
										}
										navigator.mediaSession.playbackState = "playing";
									});
									navigator.mediaSession.setActionHandler("pause", function () {
										if ("mainPlayer" in window) {
											mainPlayer.pause();
										} else {
											pp.pause();
										}
										navigator.mediaSession.playbackState = "paused";
									});
									function updatePositionState() {
										navigator.mediaSession.setPositionState({
											duration: mainPlayer.duration,
											playbackRate: mainPlayer.playbackRate,
											position: mainPlayer.currentTime,
										});
									}
									navigator.mediaSession.setActionHandler("seekbackward", function () {
										if ("mainPlayer" in window) {
											mainPlayer.seek(mainPlayer.getTime() - 5);
										} else {
											pp.currentTime -= 5;
										}
										try {
											updatePositionState();
										} catch (_ex) {}
									});
									navigator.mediaSession.setActionHandler("seekforward", function () {
										if ("mainPlayer" in window) {
											mainPlayer.seek(mainPlayer.getTime() + 5);
										} else {
											pp.currentTime += 5;
										}
										try {
											updatePositionState();
										} catch (_ex) {}
									});
									try {
										updatePositionState();
									} catch (_ex) {}
								}
							});
							run_async(function () {
								if (isValidObject(jsonObject.videos.preferred.video) && isValidObject(jsonObject.videos.preferred.audio)) {
									const supportsMSE = window.MediaSource || window.webkitMediaSource;
									if (window.dashjs && PLAYBACK_ENGINE === "dash.js") {
										const player = dashjs.MediaPlayer().create({
											settings: {
												streaming: {
													fastSwitchEnabled: !window.isIE11,
													stableBufferTime: 15,
													bufferToKeep: getBufferSize(),
													bufferTimeAtTopQualityLongForm: getHQBufferSize(),
													retryIntervals: {
														InitializationSegment: 133,
														IndexSegment: 133,
														MediaSegment: 133,
														BitstreamSwitchingSegment: 133,
														other: 133,
													},
												},
											},
										});
										window.ndashPlayer = player;
										player.initialize(mainPlayer, "/b64_dec?td=" + jsonObject.videos.muxedPayload, true);
										console.debug("ndashPlayer: Using buffer size of " + getBufferSize() + " seconds.");
										var __n = 0;
										if (PREFER_QUALITY != null) {
											__n = PREFER_QUALITY;
										}
										player.on(dashjs.MediaPlayer.events.STREAM_INITIALIZED, function () {
											console.debug("nDashJS: Bitrates: " + player.getBitrateInfoListFor("video"));
											console.debug("nDashJS: Current Quality: " + player.getQualityFor("video"));
											var br = player.getBitrateInfoListFor("video");
											if (DASH_JS_ENABLE_QUALITY_ENFORCEMENT) {
												console.debug("[ndashPlayer] Enforcing initial quality.");
												for (var i = 0; i < br.length; i++) {
													var q = br[i].height;
													var next = br[i + 1];
													if (q === __n) {
														if (next !== undefined && next !== null) {
															// fix to get 60 fps to be preferred
															var qn = next.height;
															if (q === qn) {
																player.setQualityFor("video", i + 1);
																break;
															}
														}
														player.setQualityFor("video", i);
														break;
													}
												}
											}
										});
										mainPlayer.play();
										mainPlayer.controls = true;
									} else if (PLAYBACK_ENGINE === "rxplayer") {
										loadScripts(["/resources/rx-player.min.js"], function () {
											const rx_cfg = {
												videoElement: mainPlayer,
												stopAtEnd: false,
												throttleVideoBitrateWhenHidden: true,
												wantedBufferAhead: getBufferSize(),
												wasmUrl: "/resources/mpd-parser.wasm",
												preferredAudioTracks: [
													{
														codec: {
															/* DTS is nice but good luck finding a browser that supports it lol */ test: /dtse/,
															all: true,
														},
													},
													{
														codec: {
															/* EAC3 > AC3 */ test: /ec-3/,
															all: true,
														},
													},
													{
														codec: {
															/* Totally not Dolby [copyright] Audio */ test: /ac-3/,
															all: true,
														},
													},
													{
														codec: {
															/* Opus provides greater audio quality than AAC-LC */ test: /opus/,
															all: true,
														},
													},
													{
														codec: {
															/* Still use AAC-LC for other devices */ test: /mp4a/,
															all: true,
														},
													},
												],
											};
											if (DASH_JS_ENABLE_QUALITY_ENFORCEMENT) {
												rx_cfg["initialVideoBitrate"] = 3571034;
											}
											const player = new RxPlayer(rx_cfg);
											window.playerInstance = player;
											player.addEventListener("error", function (err) {
												console.error("The content stopped with the following error", err);
											});
											mainPlayer.controls = true;
											player.loadVideo({
												url: "/b64_dec?td=" + jsonObject.videos.muxedPayload + "&dashMime",
												transport: "dash",
												autoPlay: true,
											});
										});
									} else if (PLAYBACK_ENGINE === "redwood") {
										id("video_primary_div").innerHTML = "";
										id("video_primary_div").id = "player-api";
										var vjs_css = document.createElement("link");
										vjs_css.href = "/resources/redwood/player.css";
										vjs_css.rel = "stylesheet";
										vjs_css.type = "text/css";
										vjs_css.media = "all";
										document.head.appendChild(vjs_css);
										window._yt_player = window._yt_player || {};
										id("player-api").innerHTML = "<script>if (window.ytcsi) {window.ytcsi.tick(\"cfg\", null, '');}<\/script>";
										//"/resources/redwood/youtube_www_embed_player.js",
										loadScripts(["/resources/redwood/redwood_preprocessor.js", "/resources/redwood/youtube_base.js", "/resources/redwood/redwood.js"], function () {
											window.ytObject = Redwood.initPlayer(VIDEO_ID, jsonObject);
											id("player-api").style.height = "100%";
											var yt_fixes = document.createElement("style");
											// FIXME-REDWOOD: top 0px !important fixes but breaks not standard height videos.
											yt_fixes.innerHTML =
												".video-stream {width: auto !important; width: -moz-available !important; width: -webkit-fill-available !important; width: fill-available !important; bottom: 0px !important; left: 0px !important; top: 0px !important; height: auto !important; margin: 0 auto; top: 0px !important; height: 100% !important; height: -moz-available !important; height: -webkit-fill-available !important; height: fill-available !important;} .ytp-cued-thumbnail-overlay-image {z-index: 11;}";
											if (isChromeFunc()) {
												yt_fixes.innerHTML = ".video-stream {height: -webkit-fill-available !important; width: 100% !important; bottom: 0px !important; left: 0px !important; top: 0px !important;}";
											} else {
											}
											document.head.appendChild(yt_fixes);
											try {
												waitForElementToDisplay(
													".html5-video-info-panel-content",
													function () {
														var o = document.getElementsByClassName("html5-video-info-panel-content")[0];
														var e = document.createElement("div");
														var y = document.createElement("div");
														y.innerHTML = "Redwood Version";
														e.appendChild(y);
														var n = document.createElement("span");
														n.innerHTML = Redwood.version;
														e.appendChild(n);
														o.appendChild(e);
													},
													500,
													15000
												);
											} catch (e) {
												console.error(e);
											}
										});
									} else {
										window.mainPlayer = new nPlayerNX(mainPlayer, audioPlayer);
										try {
											mainPlayer.src = jsonObject.videos.videoStreams[jsonObject.videos.preferred.video].proxied_url;
											audioPlayer.src = jsonObject.videos.audioStreams[jsonObject.videos.preferred.audio].proxied_url;
											window.mainPlayer.play();
											mainPlayer.controls = true;
										} catch (e) {
											console.error(e);
											window.mainPlayer.applySource(jsonObject.videos.combinedStreams[jsonObject.videos.preferred.comb].proxied_url, null);
											window.mainPlayer.play();
											mainPlayer.controls = true;
										}
									}
								} else {
									var videoURL = jsonObject.videos.combinedStreams[jsonObject.videos.preferred.comb].proxied_url;
									if (videoURL.endsWith(".m3u8") || jsonObject.videos.combinedStreams[jsonObject.videos.preferred.comb].liveStream) {
										var script = document.createElement("script");
										script.setAttribute("crossorigin", "true");
										script.onload = function () {
											if (supportsHLSWorkedAround(mainPlayer)) {
												console.info("Handling livestream, hold on... (method=hls_native)");
												mainPlayer.src = videoURL;
												mainPlayer.controls = true;
											} else if (Hls.isSupported()) {
												console.info("Handling livestream, hold on... (method=hls)");
												var config = {
													defaultAudioCodec: "mp4a.40.2",
													liveDurationInfinity: true,
													fragLoadingTimeOut: 80000,
													maxBufferLength: isMobile || is_iPhoneOS() ? 30 : navigator.userAgent.contains("CrKey") ? 45 : 120,
												};
												var hls = new Hls(config);
												hls.loadSource(videoURL);
												hls.attachMedia(mainPlayer);
												hls.on(Hls.Events.MANIFEST_PARSED, function () {
													mainPlayer.play();
													mainPlayer.controls = true;
												});
											} else {
												console.info("Handling livestream, hold on... (method=fallback)");
												alert("nTube: Failed to handle livestream.\nhls.js isn't supported by your browser.");
												mainPlayer.src = videoURL;
												mainPlayer.controls = true;
											}
										};
										script.src = "/resources/hls.js";
										document.head.appendChild(script);
									} else {
										window.mainPlayer = new nPlayerNX(mainPlayer, audioPlayer);
										window.mainPlayer.applySource(jsonObject.videos.combinedStreams[jsonObject.videos.preferred.comb].proxied_url, null);
										window.mainPlayer.play();
										mainPlayer.controls = true;
									}
								}
								run_async(function () {
									const loop = getQueryVariable("loop");
									if (loop !== null && loop !== undefined && (loop === "1" || loop === "true")) {
										mainPlayer.loop = true;
									}
									const controls = getQueryVariable("controls");
									if (controls !== null && controls !== undefined && (controls === "1" || controls === "true")) {
										mainPlayer.controls = true;
									} else if (controls !== null && controls !== undefined && (controls === "0" || controls === "false")) {
										mainPlayer.controls = false;
									}
								});
							});
							run_async(function () {
								if (jsonObject.captions) {
									for (var i = 0; i < jsonObject.captions.length; i++) {
										var caption = jsonObject.captions[i];
										var track = document.createElement("track");
										track.kind = "captions";
										track.label = caption.text;
										track.srclang = caption.code;
										track.src = caption.url;
										mainPlayer.appendChild(track);
									}
								}
							});
						}
					}
				);
				run_async(function () {
					document.body.style.cursor = "wait";
				});
			}
		</script>
	</head>

	<body style="padding: 0px; margin: 0px">
		<div id="overlay">
			<div id="text" style="text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000">Press ANYWHERE to begin.</div>
		</div>
		<script>
			function unhideVideoInfo() {
				//console.log("focus()");
				document.getElementById("video-overlay").style.display = "";
				document.getElementById("video-overlay").style.visibility = "";
			}
			function hideVideoInfo() {
				document.getElementById("video-overlay").style.display = "none";
				document.getElementById("video-overlay").style.visibility = "hidden";
			}
		</script>
		<div>
			<div id="video_primary_div">
				<!--Used for 360 video support to override the element for a canvas.-->
				<video id="_primary_player" style="width: 100%; height: 100%; padding-left: 0px; image-rendering: auto; display: block" decoding="async" loading="lazy" controller="true" autoplay></video>
			</div>
			<video id="_secondary_player" style="visibility: hidden; display: none" autoplay></video>
		</div>
		<div class="video-info-overlay" onmouseover="unhideVideoInfo();" onmouseout="hideVideoInfo();">
			<div id="video-overlay" style="display: none; visibility: hidden; font-size: 1.8vw">
				<h3
					style="
						width: 70%;
						margin-left: 10px;
						margin-top: 10px;
						margin-bottom: 5px;
						font-style: normal;
						-webkit-font-smoothing: antialiased;
						-moz-osx-font-smoothing: grayscale;
						text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
						float: left;
						font-size: 1.2em;
						vertical-align: middle;
					"
					id="video-title"
				>
					Loading...
				</h3>
				<a href="#noDoNot" id="url-fix">
					<h3
						style="
							color: white;
							text-decoration: none;
							margin-right: 10px;
							margin-top: 10px;
							margin-bottom: 5px;
							font-style: normal;
							-webkit-font-smoothing: antialiased;
							-moz-osx-font-smoothing: grayscale;
							text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
							float: right;
							vertical-align: middle;
							font-size: 1.2em;
						"
					>
						Watch on <span style="color: red">n</span><span style="color: lightgreen">Tube</span>
					</h3>
				</a>
				<div style="clear: both"></div>
				<p id="video-overlay-info" style="margin-left: 10px; margin-top: 5px; display: none; visibility: hidden; text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000">Information String.</p>
			</div>
		</div>
		<script>
			if (getQueryVariable("autoplay") !== null) {
				document.getElementById("overlay").style.display = "none";
				document.getElementById("overlay").style.visibility = "hidden";
				run_async(init);
			} else {
				document.getElementById("overlay").onclick = function () {
					document.getElementById("overlay").style.display = "none";
					document.getElementById("overlay").style.visibility = "hidden";
					run_async(init);
				};
			}
			run_async(function () {
				if (window.location.toString().contains("file:///")) {
					return;
				}
				var VIDEO_ID = getQueryVariable("v");
				if (VIDEO_ID.contains("?")) {
					VIDEO_ID = VIDEO_ID.substring(0, VIDEO_ID.indexOf("?"));
				}
				if (VIDEO_ID.contains("?")) {
					VIDEO_ID = VIDEO_ID.substring(0, VIDEO_ID.indexOf("?"));
				}
				if (VIDEO_ID == null || VIDEO_ID.length == 0) {
					return;
				}
				const video = document.getElementById("_primary_player");
				video.poster = "https://i.ytimg.com/vi/" + VIDEO_ID + "/maxresdefault.jpg";
				var img = new Image();
				img.src = video.getAttribute("poster");
				img.onload = function () {
					if (this.naturalWidth === 120) {
						video.poster = this.currentSrc.replace("maxresdefault", "mqdefault");
					}
				};
			});
		</script>
	</body>
</html>
